https://bugs.gentoo.org/768339

--- a/src/mongo/db/exec/plan_stats.h
+++ b/src/mongo/db/exec/plan_stats.h
@@ -33,6 +33,7 @@
 #include <cstdlib>
 #include <string>
 #include <vector>
+#include <optional>

 #include "mongo/db/index/multikey_paths.h"
 
